<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:p="http://primefaces.prime.com.tr/ui"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:ui="http://java.sun.com/jsf/facelets">
    
    <f:view beforePhase="#{addNewBranchManagedBean.initView}">

        <h:head>
            <title>Add New Branch</title>
        </h:head>

        <h:body>

            <h:form id="frmAddNewBranch" prependId="false">

                <p:panel id="panelAddNewBranch" header="Add New Branch">

                    <p:messages id="statusMessages" />

                    <p:tabView id="tabViewAddNewBranch" dynamic="false">

                        <p:tab id="tabBranchContactInformation" title="Branch and Contact Information">

                            <h:panelGrid columns="3" cellpadding="10">

                                <h:outputLabel for="branchName" style="font-weight: bold" value="Branch Name: * " />
                                <h:inputText autocomplete="off" required="true" label="Branch Name" requiredMessage="Branch Name is required." id="branchName" value="#{addNewBranchManagedBean.branch.branchName}"/>
                                <p:message for="branchName" />

                                <h:outputLabel for="postalCode" style="font-weight: bold" value="Postal Code: * " />
                                <h:inputText autocomplete="off" required="true" maxlength="6" size="6" label="Postal Code" requiredMessage="Postal Code is required." id="postalCode" value="#{addNewBranchManagedBean.branch.branchAddress.postalCode}"> 
                                    <f:validateLength minimum="6" maximum="6" />
                                </h:inputText>
                                <p:message for="postalCode" />

                                <h:outputLabel for="houseNumber" style="font-weight: bold" value="Blk/House No: * " />
                                <h:inputText autocomplete="off" required="true" label="House Number" requiredMessage="Blk/House No is required." id="houseNumber" value="#{addNewBranchManagedBean.branch.branchAddress.houseNumber}"/>
                                <p:message for="houseNumber" />

                                <h:outputLabel for="streetName" style="font-weight: bold" value="Street Name: * " />
                                <h:inputText required="true" requiredMessage="Street Name is required." label="Street Name" id="streetName" value="#{addNewBranchManagedBean.branch.branchAddress.streetName}"/>
                                <p:message for="streetName" />

                                <h:outputLabel for="buildingName" style="font-weight: bold" value="Building Name: " />
                                <h:inputText label="Building Name" id="buildingName" value="#{addNewBranchManagedBean.branch.branchAddress.buildingName}"/>
                                <p:message for="buildingName" />

                                <h:outputLabel for="contactNumber" style="font-weight: bold" value="Contact Number: * " />  
                                <p:inputMask required="true" requiredMessage="Contact Number is required." value="#{addNewBranchManagedBean.branch.contactNumber}" id="contactNumber" mask="(999)-99999999"/>  
                                <p:message for="contactNumber" />

                                <h:outputLabel for="contactPerson" style="font-weight: bold" value="Contact Person: * " />
                                <h:inputText required="true" requiredMessage="Contact Person is required." label="Contact Person" id="contactPerson" value="#{addNewBranchManagedBean.branch.contactPerson}"/>
                                <p:message for="contactPerson" />

                            </h:panelGrid>

                        </p:tab>
                        
                        <p:tab id="tabBranchSpecificInformation" title="Branch Specific Information">
                            
                            <h:panelGrid  columns="3" cellpadding="10">
                                
                                <h:outputLabel style="font-weight: bold" value="Cuisine Type(s): * " />
                                <h:selectManyCheckbox required="true" id="cuisineTypes" value="#{addNewBranchManagedBean.cuisineTypes}" converter="cuisineTypeConverter">
                                    <f:selectItems value="#{addNewBranchManagedBean.cuisineTypeSelectItems}" />
                                </h:selectManyCheckbox>
                                <p:message for="cuisineTypes"/>
                                
                                <h:outputLabel for="fnbType" style="font-weight: bold" value="FnB Type: * " />
                                <h:selectOneMenu required="true" id="fnbType" value="#{addNewBranchManagedBean.branch.fnBBranch.fnBTypeEnumId}" converter="fnbTypeConverter" >
                                    <f:selectItems id="fnbTypeSelectItems" value="#{addNewBranchManagedBean.fnbTypeSelectItems}" />
                                </h:selectOneMenu>
                                <p:message for="fnbType"/>
                                
                                <h:outputLabel for="isHalal" style="font-weight: bold" value="Halal Type: * " />
                                <h:selectOneRadio required="true" requiredMessage="Halal Type is required" id="isHalal" value="#{addNewBranchManagedBean.branch.fnBBranch.isHalal}">
                                    <f:selectItems value="#{addNewBranchManagedBean.isHalalSelectItems}"/>
                                </h:selectOneRadio>
                                <p:message for="isHalal"/>
                                
                                <h:outputLabel for="priceRange" style="font-weight: bold" value="Price Range: * " />
                                <h:selectOneMenu id="priceRange" required="true" value="#{addNewBranchManagedBean.branch.fnBBranch.priceRange}">
                                    <f:selectItems value="#{addNewBranchManagedBean.priceRangeSelectItems}"/>
                                </h:selectOneMenu>
                                <p:message for="priceRange" />
                                                                
                            </h:panelGrid>
                            
                        </p:tab>
                        
                        <p:tab id="tabBranchOperatingHours" title="Branch Operating Hours">
                            
                            <h:panelGrid columns="3" cellpadding="10">
                                
                                <h:outputLabel for="mondayStart" style="font-weight: bold" value="Monday: " />
                                <h:selectOneMenu required="true" id="mondayStart" value="#{addNewBranchManagedBean.mondayStart}" converter="operatingHoursConverter">
                                    <f:selectItems id="operatingHoursSelectItems" value="#{addNewBranchManagedBean.operatingHoursSelectItems}"/>
                                </h:selectOneMenu>
                                <p:message for="mondayStart" />
                                
                            </h:panelGrid>
                            
                        </p:tab>

                    </p:tabView>

                    <p:ajaxStatus style="width:16px;height:16px;">

                        <f:facet name="start">
                            <h:graphicImage value="/images/ajaxloading.gif" />
                        </f:facet>

                        <f:facet name="complete">
                            <h:outputText value="" />
                        </f:facet>

                    </p:ajaxStatus>
                    
                    <p:commandButton id="cmdSaveNewBranch" value="Save New Branch" update="statusMessages tabViewAddNewBranch" ajax="true" actionListener="#{addNewBranchManagedBean.saveNewBranch}" />

                </p:panel>                               

            </h:form>

        </h:body>
        
    </f:view>
    
</html>

